function trans_var = transform_var(matchedDS,varargin)

p = inputParser;
defaultColor = [0.8 0.8 0.8];

addOptional(p,'color',defaultColor,@(x) (length(x)==3));

parse(p,varargin{:});

FigColor = p.Results.color;

% list of variables that shouldn't show up as transformable
BannedVarnames = {...
    'DateTime',...
    'R'     ,...
    'MB'    ,...
    'WCB'   ,...
    'SCB'    ...
    };

% list of available transformations
transformations = {'pow5','pow4','pow3','pow2',...
    'root2','root3','root4','root5','log10','ln'};

% initialize variables to fill
TransformVar = [];
trans = [];
trans_var = {};

% get the variable names
ModelVarNames   = matchedDS.Properties.VarNames;

% remove banned variable names
for k = length(ModelVarNames):-1:1    
    if any(strcmp(ModelVarNames{k},BannedVarnames))
        ModelVarNames(k) = [];
    end
end

% set up gui
MainFig = figure(...
    'Units',            'normalized',...
    'Position',         [0.75/2 0.75/2 0.25 0.15],...
    'Color',            FigColor,...
    'MenuBar',          'none',...
    'WindowStyle',      'modal',...    
    'Name',             'Transform variable',...
    'NumberTitle',      'off', ...
    'CloseRequestFcn', @CloseRequestFcn ...
    );


MainFigColor = get(MainFig,'color');

mdlVarStaticText = uicontrol(...
    'Style',    'text',...
    'Units',    'normalized',...
    'Position', [0.15 0.78 0.3 0.1],...
    'BackgroundColor', MainFigColor,...
    'String',   'Variable:'...
    );

transStaticText = uicontrol(...
    'Style',    'text',...
    'Units',    'normalized',...
    'Position', [0.15 0.53 0.3 0.1],...
    'BackgroundColor', MainFigColor,...    
    'String',   'Transformation:'...
    );

mdlVarPopupmenu = uicontrol(...
    'Style',    'popupmenu',...
    'Units',    'normalized',...
    'Position', [0.5 0.75 0.3 0.15],...
    'BackgroundColor', [1 1 1],...
    'String',   ['-' ModelVarNames],...
    'Callback', @mdlVarPopupmenu_callback...
    );

transPopupmenu = uicontrol(...
    'Style',    'popupmenu',...
    'Units',    'normalized',...
    'Position', [0.5 0.5 0.3 0.15],...
    'BackgroundColor', [1 1 1],...
    'String',   ['-' transformations],...
    'Callback', @transPopupmenu_callback...
    );

selectVarButton = uicontrol(...
    'Style',    'pushbutton',...
    'Units',    'normalized',...
    'Position', [0.15 0.15 0.3 0.20],...
    'String',   'Select Variable',...
    'Callback', @selectVarButton_callback...
    );

cancelButton = uicontrol(...
    'Style',    'pushbutton',...
    'Units',    'normalized',...
    'Position', [0.50 0.15 0.3 0.20],...
    'String',   'Cancel',...
    'Callback', @cancelButton_callback...
    );

uiwait(MainFig);

% if the transformed variable and transformation are valid
if ~isempty(TransformVar) && ~isempty(trans) && ...
        ~strcmp(TransformVar,'-') && ~strcmp(trans,'-')
    
    % add the variable and transformation to the returned cell array
    trans_var{1,1} = TransformVar;
    trans_var{1,2} = trans;

end

    function mdlVarPopupmenu_callback(hObject,~)

    end

    function transPopupmenu_callback(hObject,~)
        
    end

    function selectVarButton_callback(hObject,~)

        % get the contents of the variable popup menu
        contents = cellstr(get(mdlVarPopupmenu,'String'));
        
        % get the selected variable
        TransformVar = contents{get(mdlVarPopupmenu,'Value')};
        
        % get the contents of the transformation popup menu
        contents = cellstr(get(transPopupmenu,'String'));
        
        % get the selected transformation
        trans = contents{get(transPopupmenu,'Value')};
        
        % close the figure
        close(MainFig);
        
    end

    function cancelButton_callback(hObject,~)
        
        % close the figure
        close(MainFig);        
        
    end


    function CloseRequestFcn(hObject,eventdata)
        
        % Hint: delete(hObject) closes the figure
        % delete(hObject);
%         if isequal(get(hObject,'waitstatus'),'waiting')
%             uiresume(hObject);
%         else
            delete(hObject);
%         end
        
    end


end


